package com.ruoyi.web.controller.business;

import java.util.List;

import com.ruoyi.business.domain.dto.ModelingManagementFormDTO;
import com.ruoyi.business.domain.dto.ModelingManagementQueryDTO;
import com.ruoyi.business.domain.vo.ModelingManagementVO;
import com.ruoyi.business.service.IModelingManagementService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 建模管理Controller
 *
 * @author yangmeng
 * @date 2023-06-01
 */
@RestController
@RequestMapping("/business/model")
public class ModelingManagementController extends BaseController {

    @Autowired
    private IModelingManagementService modelingManagementService;

    /**
     * 查询建模管理列表
     */
    @PreAuthorize("@ss.hasPermi('business:management:list')")
    @GetMapping("/list")
    public TableDataInfo list(ModelingManagementQueryDTO managementQueryDTO) {
        startPage();
        List<ModelingManagementVO> list = modelingManagementService.selectModelingManagementList(managementQueryDTO);
        return getDataTable(list);
    }


    /**
     * 获取建模管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:management:query')")
    @GetMapping(value = "/{modelingId}")
    public AjaxResult getInfo(@PathVariable("modelingId") Long modelingId) {
        return success(modelingManagementService.selectModelingManagementByModelingId(modelingId));
    }

    /**
     * 新增建模管理
     */
    @PreAuthorize("@ss.hasPermi('business:management:add')")
    @PostMapping
    public AjaxResult add(@RequestBody ModelingManagementFormDTO modelingManagementFormDTO) {
        return AjaxResult.success(modelingManagementService.insertModelingManagement(modelingManagementFormDTO));
    }

    /**
     * 修改建模管理
     */
    @PreAuthorize("@ss.hasPermi('business:management:edit')")
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody ModelingManagementFormDTO modelingManagementFormDTO) {
        return toAjax(modelingManagementService.updateModelingManagement(modelingManagementFormDTO));
    }

    /**
     * 删除建模管理
     */
    @PreAuthorize("@ss.hasPermi('business:management:remove')")
    @PostMapping("/delete/{modelingIds}")
    public AjaxResult remove(@PathVariable Long[] modelingIds) {
        return toAjax(modelingManagementService.deleteModelingManagementByModelingIds(modelingIds));
    }
}
